/*
 * 
 * Version 1.00
 * 
 * Created on 2007-6-4
 * Encoding GB2312
 */
package net.comm.group.service.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.List;
import java.util.Vector;

import net.comm.check.service.impl.JifenServiceImpl;
import net.comm.common.GlbFinal;
import net.comm.common.ReturnMessage;
import net.comm.message.service.impl.MessageServiceImpl;
import net.comm.message.web.form.MessageForm;
import net.comm.message.web.form.MsgcontForm;
import net.comm.param.service.impl.SequenceMgr;
import net.comm.common.common;


import net.comm.group.bean.BaseGMember;
import net.comm.group.bean.BaseGroups;
import net.comm.group.db.DbGMemberService;
import net.comm.group.db.DbGroupsService;
import net.comm.group.db.GMemberServiceSqlMysql;
import net.comm.group.db.GroupsServiceSqlMysql;
import net.comm.group.web.form.GMemberForm;
import net.comm.group.web.form.GroupsForm;
import net.comm.group.web.form.GsignupForm;
import net.comm.page.PageCtr;

import net.comm.tags.JstlFun;
import net.comm.user.service.impl.UserSysinfoServiceImpl;
import net.comm.user.web.form.UserSysinfoForm;
import net.comm.util.DatetimeUtil;
import net.comm.util.DbcpPool;
import net.comm.util.HtmlMessageBox;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.log4j.Logger;
import org.sakaiproject.db.impl.BasicSqlService;


/**
 *
 * @author hcgong(hcgong@sina.com)
 * @version 1.0
 * @date 2007-6-4
 */
public class GMemberServiceImpl {

	static Logger logger = Logger.getLogger(GMemberServiceImpl.class.getName());

	/**
	 * 
	 * @see net.IUserbasicService.module.other.IUserService
	 * 		#list(net.swift.module.other.ExaQueryBean, net.swift.common.ReturnMessage)
	 */
	public List list(GMemberForm theForm,  ReturnMessage msg) 
	{
		List list = null;

		Connection cn = null;

		try
		{
			cn = DbcpPool.getConnection();
			
			GMemberServiceSqlMysql servSql = new GMemberServiceSqlMysql();
			BasicSqlService  bSqlServ = new BasicSqlService();

			Object[] fields2 = new Object[1];
			fields2[0] = theForm.getQryGroupID();

			/*
			 * 获得查询SQL语句
			 */
			String sql = servSql.getCountSql3();

			/**
			 * 根据SQL执行结果计算分页相关信息
			 */
			PageCtr page = theForm.getPage();
			page.setTotalNum(bSqlServ.dbCount(cn, sql, fields2));
			page.caculate();

			//取得FORM中传入的查询参数
			Object[] fields = new Object[3];
			
			fields[0] = theForm.getQryGroupID();
			fields[1] = page.getPos()-1;
			fields[2] = page.getPageSize();
			
			sql = servSql.getRecbyPage2Sql();

			list = bSqlServ.dbRead(cn, sql, fields, new DbGMemberService());
			
		    DbcpPool.returnConnection(cn);
		    
		} catch(Exception ex) 
		{
			/**
			 * 记录相关日志
			 */
			logger.error(ex.getMessage());
			try 
			{
				DbcpPool.rollBackTran(cn);
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
			} catch(Exception ex1) 
			{
				ex1.printStackTrace();
				logger.error("事务回滚操作失败!ExaServiceImpl->add(01)" , ex1);
			}			
			
		} finally {
			DbcpPool.returnConnection(cn);
		}		
		
		return list;
	}
	
	/**
	 * 
	 * @see net.IUserbasicService.module.other.IUserService
	 * 		#list(net.swift.module.other.ExaQueryBean, net.swift.common.ReturnMessage)
	 */
	public List adlist(GMemberForm theForm,  ReturnMessage msg) 
	{
		List list = new Vector();

		Connection cn = null;
		Statement stmt=null;
		ResultSet rs=null;
		try
		{
			cn = DbcpPool.getConnection();
			
			GMemberServiceSqlMysql servSql = new GMemberServiceSqlMysql();
			
			StringBuffer sb = new StringBuffer(" where 1=1 ");
			
			String qryType = theForm.getQryType().replaceAll(GlbFinal.SQLINjection, " ").trim();
			if(!qryType.equals("")){
				
				if(qryType.equals(GlbFinal.GROUPMEMBER_CREATOR_MANAGER)){//查询创建者和管理员
					
					sb.append(" and (Type ='");
					sb.append(GlbFinal.GROUPMEMBER_CREATOR);
					sb.append("' or type = '");
					sb.append(GlbFinal.GROUPMEMBER_MANAGER);
					sb.append("' )");
					
				}else{
					
					sb.append(" and Type ='");
					sb.append(qryType);
					sb.append("'");
				}
			}

			if(theForm.getQryGroupID() > 0){
				
				sb.append(" and GroupID =");
				sb.append(theForm.getQryGroupID());
				sb.append(" ");
			}
			
			if(theForm.getQryUserID() > 0 ){
				
				sb.append(" and UserID = ");
				sb.append(theForm.getQryUserID());
				sb.append(" ");
			}

			//查询记录数
			stmt = cn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
			String sql = servSql.getCountSql1();

			logger.debug(sql+sb.toString());
			rs=stmt.executeQuery(sql+sb.toString());
			int nRows = 0;
			if (rs.next())
	           nRows = rs.getInt("COUNT");
			else
			{
	            rs.close();
	            stmt.close();
	            DbcpPool.returnConnection(cn);
			    return list;
			}
			
			/**
			 * 根据SQL执行结果计算分页相关信息
			 */
			PageCtr page = theForm.getPage();
			page.setTotalNum(nRows);
			page.caculate();
		
			sb.append(" limit ");
			sb.append(page.getPos()-1);
			sb.append(", ");
			sb.append(page.getPageSize());
			
			 //取记录
			 sql = servSql.getRecSql();
			 logger.debug(sql+sb.toString());
			 DbGMemberService dbservice = new DbGMemberService();
			 
			 rs=stmt.executeQuery(sql+sb.toString());
			 while (rs.next())
			 {
				try
				{
					Object obj = dbservice.readSqlResultRecord(rs);
					if (obj != null) list.add(obj);
				}
				catch (Throwable t)
				{
					logger.error(t.getMessage());
				}		
			 }
			 rs.close();
			 stmt.close();
		     DbcpPool.returnConnection(cn);

		} catch(Exception ex) 
		{
			/**
			 * 记录相关日志
			 */
			logger.error(ex.getMessage());
			try {
				if (rs != null)
					rs.close();
				if (stmt != null)
					stmt.close();
				DbcpPool.returnConnection(cn);
			} catch (Exception ex1) {
				ex1.printStackTrace();
			}			
	    }finally {
			try {
				if (rs != null)
					rs.close();
				if (stmt != null)
					stmt.close();
			} catch (Exception ex) {
				ex.printStackTrace();
			}			
			DbcpPool.returnConnection(cn);
		}		
		return list;
	}	

	/**
	 * 返回根据会员ID查询的会员操作日志
	 */
	public List listmanager(int  groupID) 
	{
		List list = null;
		Connection cn = null;

		try
		{
			cn = DbcpPool.getConnection();
			
			//取得FORM中传入的查询参数
			Object[] fields = new Object[1];
			
			fields[0] = groupID;			

			GMemberServiceSqlMysql servSql = new GMemberServiceSqlMysql();
						
			BasicSqlService  bSqlServ = new BasicSqlService();

			/*
			 * 获得查询SQL语句
			 */
			String sql = servSql.getRecbyManagerSql();
									
			list = bSqlServ.dbRead(cn, sql, fields, new DbGMemberService());
									
		    DbcpPool.returnConnection(cn);
		    
		} catch(Exception ex) 
		{
			/**
			 * 记录相关日志
			 */
			logger.error(ex.getMessage());
			try 
			{
				DbcpPool.rollBackTran(cn);
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
			} catch(Exception ex1) 
			{
				ex1.printStackTrace();
				logger.error("事务回滚操作失败!ExaServiceImpl->add(01)" , ex1);
			}			
			
		} finally {
			DbcpPool.returnConnection(cn);
		}
		
		return list;
	}
	/**
	 * 返回根据会员ID查询的会员操作日志
	 */
	public boolean IsManager(int  groupID, int userID) 
	{
		boolean isMan = true;
		Connection cn = null;

		try
		{
			cn = DbcpPool.getConnection();
			
			//取得FORM中传入的查询参数
			Object[] fields = new Object[2];
			
			fields[0] = groupID;			
			fields[1] = userID;			

			GMemberServiceSqlMysql servSql = new GMemberServiceSqlMysql();
			BasicSqlService  bSqlServ = new BasicSqlService();

			/*
			 * 获得查询SQL语句
			 */
			String sql = servSql.getRecbyGroupIDUserIDSql();
									
			List list = bSqlServ.dbRead(cn, sql, fields, new DbGMemberService());
			if(list.size() == 0){
				isMan = false;
			}
			
			DbcpPool.closeTran(cn);						
		    DbcpPool.returnConnection(cn);
		    
		} catch(Exception ex) 
		{
			/**
			 * 记录相关日志
			 */
			logger.error(ex.getMessage());
			try 
			{
				DbcpPool.rollBackTran(cn);
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
			} catch(Exception ex1) 
			{
				ex1.printStackTrace();
				logger.error("事务回滚操作失败!ExaServiceImpl->add(01)" , ex1);
			}			
			
		} finally {
			DbcpPool.returnConnection(cn);
		}
		
		return isMan;
	}	
	/**
	 * 返回根据会员ID查询的会员操作日志
	 */
	public List list(int  userID) 
	{
		List list = null;
		Connection cn = null;

		try
		{
			cn = DbcpPool.getConnection();
			
			//取得FORM中传入的查询参数
			Object[] fields = new Object[2];
			
			fields[0] = userID;			
			fields[1] = 20;			
			
			GMemberServiceSqlMysql servSql = new GMemberServiceSqlMysql();
						
			BasicSqlService  bSqlServ = new BasicSqlService();

			/*
			 * 获得查询SQL语句
			 */
			String sql = servSql.getByUserIDSql();
									
			list = bSqlServ.dbRead(cn, sql, fields, new DbGMemberService());
									
		    DbcpPool.returnConnection(cn);
		    
		} catch(Exception ex) 
		{
			/**
			 * 记录相关日志
			 */
			logger.error(ex.getMessage());
			try 
			{
				DbcpPool.rollBackTran(cn);
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
			} catch(Exception ex1) 
			{
				ex1.printStackTrace();
				logger.error("事务回滚操作失败!ExaServiceImpl->add(01)" , ex1);
			}			
			
		} finally {
			DbcpPool.returnConnection(cn);
		}
		
		return list;
	}	
	/**
	 * @see net.IUserbasicService.module.other.IUserService
	 * 		#get(net.swift.db.tab_paramnostro, net.swift.common.ReturnMessage)
	 */
	public void get(GMemberForm theForm, ReturnMessage msg) 
	{
		Connection cn = null;
		try
		{
			cn = DbcpPool.getConnection();
			List list = null;

			//取得FORM中传入的查询参数
			Object[] fields = new Object[2];
			
			fields[0] = theForm.getGroupID();			
			fields[1] = theForm.getUserID();			
			
			GMemberServiceSqlMysql servSql = new GMemberServiceSqlMysql();
			BasicSqlService  bSqlServ = new BasicSqlService();
			
			String sql = servSql.getbykeySql();			
					
			list = bSqlServ.dbRead(cn, sql, fields, new DbGMemberService());
			
			if(list.size() == 0){
				common.setAppFailMsg(msg , "会员不存在");
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
				return;				
			}
			
			BaseGMember base = (BaseGMember)list.get(0);
				
			BeanUtils.copyProperties(theForm, base);
			
			DbcpPool.returnConnection(cn);
			return;
			
		} catch(Exception ex) 
		{
			logger.error("System error , param get about invite" + ex);
			common.setAppFailMsg(msg , ex.getMessage());
			try 
			{
				DbcpPool.rollBackTran(cn);
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
			} catch(Exception ex1) 
			{
				ex1.printStackTrace();
				logger.error("事务回滚操作失败!ExaServiceImpl->add(01)" , ex1);
			}			
		} finally {
			DbcpPool.returnConnection(cn);
		}
		
		return ;
	}
	/**
	 * 添加会员加入群中,并报名参加活动
	 * @see net.IUserbasicService.module.other.IUserService#add(net.swift.common.ReturnMessage)
	 */
	public void addsign(GMemberForm theForm, ReturnMessage msg) 
	{
		
		Connection cn = null;
		try
		{
			cn = DbcpPool.getConnection();
			
			DbcpPool.beginTran(cn);
			
			//加入群组
			add(cn, theForm, msg);
			if(msg.getErrCode() != 0){
				return;
			}
			//添加报名到活动报名表
			GsignupServiceImpl signservice = new GsignupServiceImpl();
			
			GsignupForm signForm = new GsignupForm();
			
			signForm.setPartyID(theForm.getPartyID());
			signForm.setUserID(theForm.getUserID());
			
			signservice.add(cn, signForm, msg);
			if(msg.getErrCode() != 0){
				return;
			}
			
			DbcpPool.commitTran(cn);
			DbcpPool.closeTran(cn);
			DbcpPool.returnConnection(cn);

		} catch(Exception ex) 
		{
			common.setAppFailMsg(msg , ex.getMessage());
			logger.error("System error , param get about operlog" + ex);
			try 
			{
				DbcpPool.rollBackTran(cn);
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
			} catch(Exception ex1) 
			{
				ex1.printStackTrace();
				logger.error("事务回滚操作失败!ExaServiceImpl->add(01)" , ex1);
			}			
		} finally {
			DbcpPool.returnConnection(cn);
		}
		
		return ;
	}
	/**
	 * 添加会员加入群中
	 * @see net.IUserbasicService.module.other.IUserService#add(net.swift.common.ReturnMessage)
	 */
	public void add(GMemberForm theForm, ReturnMessage msg) 
	{
		
		Connection cn = null;
		try
		{
			cn = DbcpPool.getConnection();
			
			DbcpPool.beginTran(cn);
			
			add(cn, theForm, msg);
			
			DbcpPool.commitTran(cn);
			DbcpPool.closeTran(cn);
			DbcpPool.returnConnection(cn);

		} catch(Exception ex) 
		{
			common.setAppFailMsg(msg , ex.getMessage());
			logger.error("System error , param get about operlog" + ex);
			try 
			{
				DbcpPool.rollBackTran(cn);
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
			} catch(Exception ex1) 
			{
				ex1.printStackTrace();
				logger.error("事务回滚操作失败!ExaServiceImpl->add(01)" , ex1);
			}			
		} finally {
			DbcpPool.returnConnection(cn);
		}
		
		return ;
	}
	/**
	 * 添加会员加入群中
	 * @see net.IUserbasicService.module.other.IUserService#add(net.swift.common.ReturnMessage)
	 */
	public void add(Connection cn, GMemberForm theForm, ReturnMessage msg) 
	{
		
		try
		{
			
			//判断是否已经加入该群组
			Object[] fields2 = new Object[2];
			
			fields2[0] = theForm.getGroupID();			
			fields2[1] = theForm.getUserID();			
			
			GMemberServiceSqlMysql servSql = new GMemberServiceSqlMysql();
			BasicSqlService  bSqlServ = new BasicSqlService();
			
			String sql = servSql.getbykeySql();			
					
			List list = bSqlServ.dbRead(cn, sql, fields2, new DbGMemberService());
			
			if(list.size()  > 0){
				common.setAppFailMsg(msg , " 已经加入部落！");
				return;				
			}			
			//取得群组信息
			GroupsServiceImpl groupservice = new GroupsServiceImpl();
			GroupsForm groupForm = new GroupsForm();
			
			groupForm.setGroupID(theForm.getGroupID());
			
			groupservice.get(groupForm, msg);
			if(msg.getErrCode() != GlbFinal.ERRCODE_SUCCESS) 
			{
				DbcpPool.rollBackTran(cn);
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
				return ;
			}
			//
			if(groupForm.getType().equals(GlbFinal.GROUP_PUBLIC)){
			
				theForm.setStatus(GlbFinal.STS_NORMAL);
			}else{
				theForm.setStatus(GlbFinal.STS_CHECKING);
			}			
			
			//取得FORM中传入的查询参数
			Object[] fields = new Object[7];
			
			fields[0] = theForm.getGroupID();
			fields[1] = theForm.getUserID();
			fields[2] = theForm.getTeamID();
			fields[3] = theForm.getType();
			fields[4] = DatetimeUtil.getDatetime();
			fields[5] = theForm.getStatus();
			fields[6] = DatetimeUtil.getDatetime();
			
			sql = servSql.getInsertSql();
						
			boolean res = bSqlServ.dbWrite(cn, sql, fields);
			if(!res){
				common.setAppFailMsg(msg , " 加入部落失败！");
				DbcpPool.rollBackTran(cn);
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
				return ;
			}

			//更新群组加入人数
			groupForm.Clear();
			groupForm.setGroupID(theForm.getGroupID());
			groupForm.setJoinNum(1);
			
			groupservice.updNum(cn, groupForm, msg);
			if(msg.getErrCode() != 0){
				
				return;
			}
			//更新会员系统表中的加入群组数
			UserSysinfoServiceImpl syservice  = new UserSysinfoServiceImpl();
			
			UserSysinfoForm sysForm = new UserSysinfoForm();
			sysForm.setUserID(theForm.getUserID());
			sysForm.setGroupNum(1);
			syservice.update(cn, sysForm, msg);
			if(msg.getErrCode() != 0){
				return;
			}	
			//修改部落创建人积分 和加入者积分
			//更新创建人积分
			JifenServiceImpl jifenservice = new JifenServiceImpl();

			jifenservice.compjf(cn, 11, groupForm.getUserID(), msg);
			if(msg.getErrCode() != 0){
				return;
			}				
			
			//更新加入者积分
			jifenservice.compjf(cn, 13, theForm.getUserID(), msg);
			if(msg.getErrCode() != 0){
				return;
			}				

		} catch(Exception ex) 
		{
			common.setAppFailMsg(msg , ex.getMessage());
			logger.error("System error , param get about operlog" + ex);
			try 
			{
				DbcpPool.rollBackTran(cn);
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
			} catch(Exception ex1) 
			{
				ex1.printStackTrace();
				logger.error("事务回滚操作失败!ExaServiceImpl->add(01)" , ex1);
			}			
		} finally {
		}
		
		return ;
	}
	/**
	 * 删除一条指定记录
	 * @see net.IUserbasicService.module.other.IUserService#update(net.swift.common.ReturnMessage)
	 */
	public void delete(GMemberForm theForm, ReturnMessage msg) 
	{
		
		Connection cn = null;
		try
		{
			cn = DbcpPool.getConnection();
			
			DbcpPool.beginTran(cn);

			GMemberServiceSqlMysql servSql = new GMemberServiceSqlMysql();
			BasicSqlService  bSqlServ = new BasicSqlService();
			
			Object[] fields = new Object[2];
			
			fields[0] = theForm.getGroupID();
			fields[1] = theForm.getUserID();
			
			String sql = servSql.getbykeySql();			
			
			List list = bSqlServ.dbRead(cn, sql, fields, new DbGMemberService());
			if(list.size() == 0){
				common.setAppFailMsg(msg , "会员不存在");
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
				return;				
			}
			BaseGMember base = (BaseGMember)list.get(0);
			if(base.getType().equals(GlbFinal.GROUPMEMBER_CREATOR)){
				
				common.setAppFailMsg(msg , "部落创建者不能退出部落");
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
				return;				
			}
			
			sql = servSql.getDeleteSql();
			
			boolean  res = bSqlServ.dbWrite(cn, sql, fields);
			if(!res){
				common.setAppFailMsg(msg , " 脱离群组失败！");
				DbcpPool.rollBackTran(cn);
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
				return;
			}

			//更新群组加入人数并取得群组信息
			GroupsServiceImpl groupservice = new GroupsServiceImpl();
			GroupsForm groupForm = new GroupsForm();
			
			groupForm.Clear();
			groupForm.setGroupID(theForm.getGroupID());
			groupForm.setJoinNum(-1);
			
			groupservice.updNum(cn, groupForm, msg);
			if(msg.getErrCode() != 0){
				
				return;
			}		
		
			//更新群组创建人积分
			JifenServiceImpl jifenservice = new JifenServiceImpl();

			jifenservice.compjf(cn, 12, groupForm.getUserID(), msg);
			if(msg.getErrCode() != 0){
				return;
			}				
			
			DbcpPool.commitTran(cn);
			DbcpPool.closeTran(cn);
			DbcpPool.returnConnection(cn);
			return;
			
		} catch(Exception ex) 
		{
			logger.error("System error , param get about invite" + ex);
			common.setAppFailMsg(msg , ex.getMessage());
			try 
			{
				DbcpPool.rollBackTran(cn);
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
			} catch(Exception ex1) 
			{
				ex1.printStackTrace();
				logger.error("事务回滚操作失败!ExaServiceImpl->add(01)" , ex1);
			}			
		} finally {
			DbcpPool.returnConnection(cn);
		}
		
		return ;
	}

	/**
	 * 更新一条指定记录
	 * @see net.IUserbasicService.module.other.IUserService#update(net.swift.common.ReturnMessage)
	 */
	public void update(GMemberForm theForm, ReturnMessage msg) 
	{
		
		Connection cn = null;
		try
		{
			cn = DbcpPool.getConnection();
			
			DbcpPool.beginTran(cn);
			
			GMemberServiceSqlMysql servSql = new GMemberServiceSqlMysql();
			BasicSqlService  bSqlServ = new BasicSqlService();
			
			//取得FORM中传入的查询参数
			Object[] fields2 = new Object[2];
			
			fields2[0] = theForm.getGroupID();			
			fields2[1] = theForm.getUserID();			
			
			String sql = servSql.getbykeySql();			
					
			List list = bSqlServ.dbRead(cn, sql, fields2, new DbGMemberService());
			if(list.size() ==0){
				common.setAppFailMsg(msg , "会员不存在");
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
				return;				
			}
			
			BaseGMember base = (BaseGMember)list.get(0);	
			if(theForm.getTeamID() == 0){
				theForm.setTeamID(base.getTeamID());
			}
			
			if(theForm.getType().equals("")){
				
				theForm.setType(base.getType());
			}
			if(theForm.getCtime().equals("")){
				
				theForm.setCtime(base.getCTime());
			}
			if(theForm.getStatus().equals("")){
				
				theForm.setStatus(base.getStatus());
			}

			//取得FORM中传入的查询参数
			Object[] fields = new Object[7];
			
			fields[0] = theForm.getTeamID();
			fields[1] = theForm.getType();
			fields[2] = theForm.getCtime();
			fields[3] = theForm.getStatus();
			fields[4] = DatetimeUtil.getDatetime();
			fields[5] = theForm.getGroupID();
			fields[6] = theForm.getUserID();
			
			sql = servSql.getUpdateSql();
						
			boolean  res = bSqlServ.dbWrite(cn, sql, fields);
			if(!res){
				common.setAppFailMsg(msg , " 更新失败！");
				DbcpPool.rollBackTran(cn);
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
				return ;
			}
			
			//对审核批准加入的会员，修改其加入群组的数量
			if(base.getStatus().equals(GlbFinal.STS_CHECKING)
					&& theForm.getStatus().equals(GlbFinal.STS_NORMAL)){
				
				UserSysinfoServiceImpl syservice  = new UserSysinfoServiceImpl();
				UserSysinfoForm sysForm = new UserSysinfoForm();

				sysForm.setUserID(theForm.getUserID());
				sysForm.setGroupNum(1);
				syservice.update(cn, sysForm, msg);
				if(msg.getErrCode() != 0){
					return;
				}				
			}
			
			DbcpPool.commitTran(cn);
			DbcpPool.closeTran(cn);
			DbcpPool.returnConnection(cn);

		} catch(Exception ex) 
		{
			common.setAppFailMsg(msg , ex.getMessage());
			logger.error("System error , param get about operlog" + ex);
			try 
			{
				DbcpPool.rollBackTran(cn);
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
			} catch(Exception ex1) 
			{
				ex1.printStackTrace();
				logger.error("事务回滚操作失败!ExaServiceImpl->add(01)" , ex1);
			}			
		} finally {
			DbcpPool.returnConnection(cn);
		}
		
		return ;
	}

}
